home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 685 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.3 KB  |  36 lines

  1. Path: news.th-darmstadt.de!news!enno
  2. From: enno@inferenzsysteme.informatik.th-darmstadt.de (Enno Sandner)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Operator Overloading
  5. Date: 05 Jan 1996 20:18:09 GMT
  6. Organization: Fachbereich Informatik, TH Darmstadt
  7. Distribution: world
  8. Message-ID: <ENNO.96Jan5211810@kitz.inferenzsysteme.informatik.th-darmstadt.de>
  9. References: <4chdhb$g64@news.cs.hope.edu>
  10. NNTP-Posting-Host: kitz.intellektik.informatik.th-darmstadt.de
  11. In-reply-to: vnopstal@cs.hope.edu's message of 4 Jan 1996 20:32:43 GMT
  12.  
  13. In article <4chdhb$g64@news.cs.hope.edu> vnopstal@cs.hope.edu (Michael Van Opstall) writes:
  14.  
  15.    A couple of questions on operator overloading:
  16.  
  17.    1. If you overload ==, do you have to overload != as well?
  18.  
  19. In general no --- However some luxery doesn't hurt.
  20. If 'a!=b' holds whenever 'a==b' is false and vice versa one could
  21. implement 'a!=b' in terms of the equality-operator:
  22.  
  23. template<class S,class T>
  24. inline bool operator != (const S& x,const T& y) { return !(x==y); }
  25.  
  26. This guarantees that either 'a==b' or 'a!=b' holds but not both at
  27. the same time.
  28.  
  29.    2. What is the accepted method for overloading >> and <<? The way I do it
  30.    is not very cool and not slick at all. Should I be including streams and doing
  31.    stream manipulation? That makes sense.
  32.  
  33. ??? 
  34.  
  35.     Enno
  36.